package io.dy.config;

import io.dy.bean.Bean_01;
import io.dy.bean.Bean_02;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.lang.reflect.Method;
import java.util.Collections;
import java.util.HashSet;

/**
 * @author : dmj
 * @date: 2024/6/3 6:53 下午
 * @description: 应用类型推断
 */
//@Configuration
public class Dy_02 {

    public static void main(String[] args) throws Exception {
        //1、创建 SpringApplication
        SpringApplication application = new SpringApplication(Dy_02.class);

        //2、反射调用 deduceFromClasspath() 方法
        Method deduceFromClasspath = WebApplicationType.class.getDeclaredMethod("deduceFromClasspath");
        deduceFromClasspath.setAccessible(true);
        System.out.println("\t 应用类型推断为:" + deduceFromClasspath.invoke(null));
    }


    @Bean
    public Bean_01 bean_01(){
        return new Bean_01();
    }

    @Bean
    public Bean_02 bean_02(){
        return new Bean_02();
    }

    @Bean
    public TomcatServletWebServerFactory servletWebServerFactory(){
        return new TomcatServletWebServerFactory();
    }
}
